<template>
  <div class="full-box shadow-box padding-box">
    <OperateCommon :showSearch="true" @search="initData">
      <template #condition>
        <el-select
          v-model="queryParams.assign_status"
          value-key=""
          placeholder="按状态查询"
          clearable
          filterable
        >
          <el-option :key="-1" label="全部" value=""></el-option>
          <el-option :key="0" label="未交办" value="0"></el-option>
          <el-option :key="1" label="已交办" value="1"></el-option>
          <el-option :key="2" label="已办结" value="2"></el-option>
        </el-select>
      </template>
    </OperateCommon>
    <div class="table-wrapper">
      <BaseTable
        :columns="columns"
        :tableData="tableData"
        :showSort="true"
        :pages="{
          show: true,
          count: count,
        }"
        :operate="{
          show: true,
          width: 150,
        }"
        @pagination="pageChange"
      >
        <template #operate="{ current }">
          <el-button type="primary" size="mini" @click="linkToDetails(current)"
            >详情</el-button
          >
        </template>
      </BaseTable>
    </div>
  </div>
</template>

<script>
import BaseTable from "@/components/Common/BaseTable.vue";
import { getInstructionsList } from "@/api/LeaderInstructions/Index";
import CalcHeight from "@/mixins/CalcHeight";
import OperateCommon from "@/components/Common/OperateCommon.vue";
import commonList from "@/mixins/commonList";
export default {
  mixins: [CalcHeight, commonList],
  components: { BaseTable, OperateCommon },
  data() {
    return {
      columns: columns,
      tableData: [],
      count: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        assign_status: "",
      },
    };
  },
  methods: {
    initData() {
      getInstructionsList(this.queryParams).then((res) => {
        if (res.code == 0) {
          this.tableData = res.data;
          this.count = res.num;
        }
      });
    },
    linkToDetails(val) {
      this.$router.push(`/instructionsDetails/${val.row.id}/1`);
    },
    pageChange(val) {
      this.queryParams.pageNum = val.pageNum;
      this.queryParams.pageSize = val.pageSize;
      this.initData();
    },
  },
  created() {
    this.initData();
  },
};

const columns = [
  {
    prop: "leader_name",
    label: "批示领导",
    width: "100",
    minWidth: "",
    align: "",
  },
  {
    prop: "project_name",
    label: "批示项目",
    width: "",
    minWidth: "150",
    align: "",
  },
  {
    prop: "instruct_content",
    label: "批示内容",
    width: "",
    minWidth: "300",
    align: "",
  },
  {
    prop: "instruct_date",
    label: "批示日期",
    width: "200",
    minWidth: "",
    align: "",
  },
  {
    prop: "assign_status_text",
    label: "状态",
    width: "80",
    minWidth: "",
    align: "",
  },
];
</script>

<style lang="scss" scoped>
</style>